package br.com.caelum.vraptor.controller;

import java.util.List;

import javax.inject.Inject;

import br.com.caelum.vraptor.Controller;
import br.com.caelum.vraptor.Result;
import br.com.caelum.vraptor.dao.GenericDAO;
import br.com.caelum.vraptor.entidades.Metas;


@Controller
public class MetasController {
	
	@Inject
	private Result result;
	
	@Inject
	private GenericDAO<Metas> dao;
	
	
	public void add(){
		
	}
	
	public List<Metas> list(){
		return dao.find();
	}
	
	public void save(Metas metas){
		dao.save(metas);
		result.redirectTo(this).list();
	}
	
	
	
	public Metas edit(Integer id){
		return dao.find(id);
	}
	
	public void delete(int id){
		Metas metas = new Metas();
		metas.setId(id);
		dao.delete(metas);
		result.redirectTo(this).list();
	}
	
}
